package com.tbit.main.controller;

import com.tbit.main.dao.core.UserDao;
import com.tbit.main.pojo.Result;
import com.tbit.main.pojo.User;
import com.tbit.manager.api.UserAuthLogApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * 用户特殊认证记录
 *
 */
@Validated
@RestController
@RequestMapping("/userAuthLog")
public class UserAuthLogController {

    @Autowired
    private UserAuthLogApi userAuthLogApi;
    @Autowired
    private UserDao userDao;
    /**
     * 清除用户特殊认证记录
     *
     * @param userId 用户id
     * @return Result<String>
     */
    @GetMapping("/cleanUserAuth")
    public Result<String> cleanUserAuth(@NotNull Integer userId) {
        User user = userDao.getByUserId(userId);
        if (user == null) {
            return Result.error("user.not.exist");
        }
        Boolean result = userAuthLogApi.cleanUserAuth(userId);
        return result ? Result.success() : Result.error();
    }

}
